package com.pxst.merchant.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.pxst.merchant.entity.SysMerchantBankCardEntity;

import com.pxst.merchant.mapper.SysMerchantBankCardMapper;

import com.pxst.merchant.req.MerchantAccountListReq;
import com.pxst.merchant.req.MerchantAccountReq;
import com.pxst.merchant.resp.MerchantAccountResp;
import com.pxst.merchant.service.SysMerchantBankCardService;

import com.pxst.resp.ApiResp;
import com.pxst.resp.PageResp;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: @Ryan
 * @Description:
 * @CreateTime: 2023-09-14 15:06
 */

@Slf4j
@Service
public class SysMerchantBankCardServiceImpl extends ServiceImpl<SysMerchantBankCardMapper, SysMerchantBankCardEntity> implements SysMerchantBankCardService {
    @Autowired
    private SysMerchantBankCardMapper sysMerchantBankCardMapper;

    @Override
    public ApiResp<PageResp<MerchantAccountResp>> getMerchantAccountListByCondietions(MerchantAccountListReq conditions) {
        PageHelper.startPage(conditions.getPage(),conditions.getRp());
        Page<MerchantAccountResp> page = (Page<MerchantAccountResp>) sysMerchantBankCardMapper.getMerChantAccountListByCondition(conditions);
        return ApiResp.page(page);
    }

    @Override
    public ApiResp updateMerchantBankCardStatus(MerchantAccountReq merchantAccountReq) {
        SysMerchantBankCardEntity entity = sysMerchantBankCardMapper.selectById(merchantAccountReq.getMerchantBankCardId());
        if(entity== null){
            return ApiResp.paramError("该账户id不存在");
        }
        entity.setStatus(merchantAccountReq.getStatus());
        sysMerchantBankCardMapper.updateById(entity);
        return ApiResp.sucess();
    }


}
